import time

# 三种
# 时间戳 timestamp
# 格式化的时间字符串
# 时间元组

time.sleep(0.1)

print(time.time())  # 1752129343.502648 float
print(f"time.localtime() = {time.localtime()}")
print(
    time.gmtime()
)  # tm_year=2025, tm_mon=7, tm_mday=10, tm_hour=6, tm_min=36, tm_sec=3, tm_wday=3, tm_yday=191, tm_isdst=0)

print(f"time.asctime() = {time.asctime()}")  # Thu Jul 10 14:37:43 2025

print(f"time.ctime() = {time.ctime()}")

t1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())  # 时间元组 -> 时间字符串
print(f"t1 = {t1}")  # 2025-07-10 14:44:46

t2 = time.strptime(
    "2025-07-10 14:44:46", "%Y-%m-%d %H:%M:%S"
)  # 时间字符串 -> struct_time 时间元组
print(
    f"t2 = {t2}"
)  # time.struct_time(tm_year=2025, tm_mon=7, tm_mday=10, tm_hour=14, tm_min=44, tm_sec=46, tm_wday=3, tm_yday=191, tm_isdst=-1)
